< previous page page_373 next page >

Page 373
Object
An object is an instance of a class. An object is a physical entity that you can interact with at runtime. An object is defined as being of the type ClassName. For example, you declare a string or integer variable like this:
9f31265bb40b592b1929e18a47ab28e5.gif
Dim strName As String
Dim intLoop As Integer
You declare an object variable in pretty much the same manner:
9f31265bb40b592b1929e18a47ab28e5.gif
Dim oEmployee As Employee
The variable oEmployee is the object you use at runtime, just as you would use a variable named strName. The important point is that you would not use Employee at runtime, just like you would not use String as a variable in your program.
Differences Between Classes and Objects
Theres a lot of confusion and misuse of the terms class and object. The two are very different from each other, but they are often used interchangeably. Once again, a class is a template. A template is a blueprint from which objects are made. An object is a physical entity that exists in memory. Each object is based on a class template.
When learning the difference between a class and an object, you might find it helpful to go back to the cookie cutter example. You know those metal (or plastic) things you stick into cookie dough. The cookie cutter can be used to create several cookies (objects). Each individual cookie is an object. However, you would not eat the metal template!
Each cookie can have different properties set on it. For example, the first cookie you create might have its PowderedSugar property set to True, whereas the second cookie might have its ColoredSprinkle property set to True. Although these objects were created from the same class, they are separate, distinct entities in memory, and each can have different properties set.
9f31265bb40b592b1929e18a47ab28e5.gif
TIP
Classes are templates, whereas objects are the actual physical entities.
Properties are only one piece of a class. The other part consists of methods that can be performed. Going back to the cookie example, the Cookie class can have several methods, such as Bake and Eat (Eat being the most prevalent).

 
< previous page page_373 next page >

If you like this book, buy it!